import axios from '@/utils/request.js'

const baseURL = 'http://127.0.0.1:3000'

const api = {
  // 测试api
  getInfo (params) {
    return axios.get(baseURL + '/system/user', params)
  },
  // 用户登录api
  userLogin (params) {
    // return axios.post('/login', params, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
    return axios.post(baseURL + '/system/login', params)
  },
  // 获取所有用户信息api
  usersInfo (params) {
    return axios.get(baseURL + '/system/usersinfo?page=' + params)
  },
  // 修改用户信息api
  editUserInfo (params) {
    return axios.post(baseURL + '/system/edituser', params)
  },
  // 注销用户api
  deleteUserInfo (params) {
    return axios.post(baseURL + '/system/deleteuser', params)
  },
  // 添加用户api
  insertUserInfo (params) {
    return axios.post(baseURL + '/system/insertUser', params)
  },
  // 文章列表查询api
  articleInfo (params) {
    return axios.get(baseURL + '/system/articlesinfo', { params })
  },
  // 添加文章api
  insertArticle (params) {
    return axios.post(baseURL + '/system/insertarticle', params)
  },
  // 修改文章api
  editArticle (params) {
    return axios.post(baseURL + '/system/editarticle', params)
  },
  // 删除文章api
  deleteArticle (params) {
    return axios.post(baseURL + '/system/deletearticle', params)
  },
  // 博客首页获取所有文章，没有分页
  initArticles (params) {
    return axios.get(baseURL + '/blog/allarticlesinfo', params)
  },
  // 获取博客标签集api
  getAllTags (params) {
    return axios.get(baseURL + '/tag', params)
  },
  // 添加标签api
  insertTag (params) {
    return axios.post(baseURL + '/inserttag', params)
  },
  // 单一查询博客文章
  queryArticle (params) {
    return axios.get(baseURL + '/blog/querybyid', { params })
  },
  // 博客用户注册
  registerUser (params) {
    return axios.post(baseURL + '/blog/register', params)
  },
  // 博客用户登录
  login (params) {
    return axios.post(baseURL + '/blog/login', params)
  },
  // 博客用户退出
  logout (params) {
    return axios.post(baseURL + '/blog/logout', params)
  },
  // id查询用户
  queryOne (params) {
    return axios.post(baseURL + '/blog/queryone', params)
  },
  // 关键字查询文章（模糊查询）
  queryByTag (params, page) {
    return axios.get(baseURL + '/blog/querybytag', { params, page })
  },
  // 获取热门标签文章
  queryHot (params) {
    return axios.get(baseURL + '/blog/queryhot', params)
  },
  queryByTitle (params) {
    return axios.get(baseURL + '/blog/querybytitle', { params })
  },
  queryByAuthor (params) {
    return axios.get(baseURL + '/blog/querybyauthor', { params })
  },
  // 文章评论IP地址
  editComment (params) {
    return axios.post(baseURL + '/blog/editcomment', params)
  },
  // 留言板信息api
  queryArtitalk (params) {
    return axios.get(baseURL + '/blog/queryartitalk', params)
  },
  // 增加留言板信息api
  insertArtitalk (params) {
    return axios.post(baseURL + '/blog/insertartitalk', params)
  },
  // 获取标签数据可视化api
  getHotTags (params) {
    return axios.post(baseURL + '/system/gethottag', params)
  },
  // 收藏以及点赞api
  collectOrLike (params) {
    return axios.post(baseURL + '/blog/collectorlike', params)
  },
  // 获取活跃用户
  queryHotUser () {
    return axios.get(baseURL + '/blog/queryhotuser')
  },
  // 添加好友以及关注作者
  addOrAttention (params) {
    return axios.post(baseURL + '/blog/addorattention', params)
  },
  // 同意或者不同意好友请求api
  agreeOrDisagree (params) {
    return axios.post(baseURL + '/blog/agreeordisagree', params)
  }

  // 获取客户端IP地址
  // getIP (params) {
  //   return axios.post('/apis', params)
  // }

}

export default api
